home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / uhren & terminkalender / time / jpclock / jpclock.c < prev    next >
C/C++ Source or Header  |  1996-04-07  |  16KB  |  466 lines

  1. /* JPClock v1.2 - © Copyright 1989 by Jonathan Potter
  2.  
  3.    This is my first, fully functional program written under Lattice C v5.02
  4.  
  5.    Anyone ever tried converting Manx code to Lattice? yuk... */
  6.  
  7. /* This program is Public Domain; do with it what you will, but if you choose
  8.  
  9.    to sell it, at least leave my name in it. */
  10.  
  11. /* Big bug fixed - thanks to Torsten Lohr for reporting it! */
  12.  
  13. #include <stdio.h>
  14. #include <ctype.h>
  15. #include <stdlib.h>
  16. #include <exec/types.h>
  17. #include <intuition/intuitionbase.h>
  18. #include <exec/memory.h>
  19. #include <libraries/dos.h>
  20. #include <libraries/dosextens.h>
  21. #include <devices/audio.h>
  22. #include <devices/timer.h>
  23. #include <exec/tasks.h>
  24. #include <string.h>
  25. #include <dos.h>
  26.  
  27. extern void bye();
  28.  
  29. /* lsr info */
  30. long _stack=4000;
  31. char *_procname="JPClock";
  32. long _priority=0;
  33. long _BackGroundIO=1;
  34. extern BPTR _Backstdout;
  35.  
  36. /* gadget ids */
  37. #define SWAPSCREENS 1
  38. #define STAYFRONT 2
  39. #define ALARM 3
  40. #define TIME 4
  41. #define ALARMTIME 5
  42. #define DATE 6
  43.  
  44. char TextBuffer[56];
  45. char TimeBuffer[10], DateBuffer[10], AlarmBuffer[10]="00:00:00";
  46.  
  47. /* the font we'll use if default > 8 point */
  48. struct TextAttr TopazText={
  49.     "topaz.font",8,0,0};
  50.  
  51. /* where all the text goes */
  52. struct IntuiText TextPrint={
  53.     1,0,JAM2,0,0,NULL,TextBuffer,NULL};
  54.  
  55. short SXYBorder[]={
  56.     -1,-1,72,-1,72,8,-1,8,-1,-1};
  57. struct Border SBorder={
  58.     0,0,3,0,JAM1,5,SXYBorder,NULL};
  59.  
  60. struct StringInfo TimeStringInfo={
  61.     TimeBuffer,NULL,0,10,0};
  62. struct StringInfo DateStringInfo={
  63.     DateBuffer,NULL,0,10,0};
  64. struct StringInfo AlarmStringInfo={
  65.     AlarmBuffer,NULL,0,10,0};
  66. struct IntuiText TimeStringText={
  67.     1,0,JAM2,-35,0,NULL,(UBYTE *)"TIME",NULL};
  68. struct IntuiText AlarmStringText={
  69.     1,0,JAM2,-43,0,NULL,(UBYTE *)"ALARM",NULL};
  70. struct IntuiText DateStringText={
  71.     1,0,JAM2,-35,0,NULL,(UBYTE *)"DATE",NULL};
  72. struct Gadget TimeStringGadget={
  73.     NULL,123,15,72,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,STRGADGET,
  74.     (APTR)&SBorder,NULL,&TimeStringText,NULL,(APTR)&TimeStringInfo,TIME,NULL};
  75. struct Gadget DateStringGadget={
  76.     &TimeStringGadget,238,15,72,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,STRGADGET,
  77.     (APTR)&SBorder,NULL,&DateStringText,NULL,(APTR)&DateStringInfo,DATE,NULL};
  78. struct Gadget AlarmStringGadget={
  79.     &DateStringGadget,361,15,72,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,STRGADGET,
  80.     (APTR)&SBorder,NULL,&AlarmStringText,NULL,(APTR)&AlarmStringInfo,ALARMTIME,NULL};
  81.  
  82. short GXYBorder[]={
  83.     -1,-1,100,-1,100,11,-1,11,-1,-1};
  84. struct Border GBorder={
  85.     0,0,3,0,JAM1,5,GXYBorder,NULL};
  86. struct IntuiText AlarmText={
  87.     1,0,JAM2,14,2,NULL,(UBYTE *)"Alarm On",NULL};
  88. struct Gadget AlarmGadget={
  89.     &AlarmStringGadget,325,30,100,11,GADGHCOMP,RELVERIFY|TOGGLESELECT,BOOLGADGET,
  90.     (APTR)&GBorder,NULL,&AlarmText,
  91.     NULL,NULL,ALARM,NULL};
  92. struct IntuiText StayFrontText={
  93.     1,0,JAM2,10,2,NULL,(UBYTE *)"Stay Front",NULL};
  94. struct Gadget StayFrontGadget={
  95.     &AlarmGadget,215,30,100,11,GADGHCOMP,RELVERIFY|TOGGLESELECT,BOOLGADGET,
  96.     (APTR)&GBorder,NULL,&StayFrontText,
  97.     NULL,NULL,STAYFRONT,NULL};
  98. struct IntuiText SwapScreensText={
  99.     1,0,JAM2,6,2,NULL,(UBYTE *)"Next Screen",NULL};
  100. struct Gadget SwapScreensGadget={
  101.     &StayFrontGadget,105,30,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  102.     (APTR)&GBorder,NULL,&SwapScreensText,
  103.     NULL,NULL,SWAPSCREENS,NULL};
  104.  
  105. struct NewWindow ClockWindow={
  106.     86,0,504,10,-1,-1,CLOSEWINDOW|MOUSEBUTTONS|GADGETUP,
  107.     WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|SMART_REFRESH|NOCAREREFRESH|RMBTRAP,
  108.     NULL,NULL,"",NULL,NULL,0,0,0,110,CUSTOMSCREEN};
  109.  
  110. struct IntuitionBase *IntuitionBase;
  111. struct IntuiMessage *Msg;
  112. struct Window *Window;
  113. struct timerequest TimeReq;
  114. struct MsgPort *TimerPort;
  115.  
  116. void main(argc,argv)
  117. int argc;
  118. char *argv[];
  119. {
  120.     /* heaps of variables, aren't there ? */
  121.     register short Chip, Fast, Total;
  122.     int dy,mn,yr,sizeflag=0,GadgetID,ScreenHeight,ScreenWidth,delay=1,
  123.         StayFront=0,Alarm=0,a,b,c,USA=0,Swap=0,j,x,y,AlarmSet=0,
  124.         DTime=1,DDay=1,DDate=1,DFast=1,DChip=1,DTotal=1,
  125.         class,code,oldx,oldy;
  126.     char d[8],Date[9],Time[9],buf[15],ch;
  127.     char *Day[7]={ "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
  128.     char *alarmstring;
  129.     struct Gadget *Gad;
  130.  
  131.     /* was I run from CLI? */
  132.     if (argc>0) {
  133.     /* yup */
  134.         if ((strncmp(argv[1],"?",1))==0) {
  135.             /* need some help */
  136.             Write(_Backstdout,"\n",-1);
  137.             Write(_Backstdout,"\x9B;0;1;2mJPClock\x9B;0;1m © Copyright 1989 by \x9B;0;1;33;4mJonathan Potter\x9B;0;1m (08-293-2788)\x9B;0m\n",-1);
  138.             Write(_Backstdout,"\n\x9B;0;33mThe ultimate Workbench clock!\x9B;0m\n\n",-1);
  139.             Write(_Backstdout,"Usage : JPClock [FLAGS]\n\nFlags are:\n\n",-1);
  140.             Write(_Backstdout,"        -a           : Set Alarm on\n",-1);
  141.             Write(_Backstdout,"        -atALARMTIME : Set Alarm time to ALARMTIME (HH:MM:SS or H:MM:SSC)\n",-1);
  142.             Write(_Backstdout,"        -dSECONDS    : Set Delay between updates to SECONDS seconds\n",-1);
  143.             Write(_Backstdout,"        -f           : Set Stay Front on\n",-1);
  144.             Write(_Backstdout,"        -ot          : Turn time display off\n",-1);
  145.             Write(_Backstdout,"        -oy          : Turn day display off\n",-1);
  146.             Write(_Backstdout,"        -od          : Turn date display off\n",-1);
  147.             Write(_Backstdout,"        -of          : Turn fast memory display off\n",-1);
  148.             Write(_Backstdout,"        -oc          : Turn chip memory display off\n",-1);
  149.             Write(_Backstdout,"        -ol          : Turn total memory display off\n",-1);
  150.             Write(_Backstdout,"        -s           : Auto. swap to next screen\n",-1);
  151.             Write(_Backstdout,"        -u           : USA format; MM-DD-YY instead of DD-MM-YY\n",-1);
  152.             Write(_Backstdout,"        -xX          : Open window with x-coordinate X\n",-1);
  153.             Write(_Backstdout,"        -yY          : Open window with y-coordinate Y\n",-1);
  154.             /* close our output channel */
  155.             Close(_Backstdout);
  156.             /* and get outahere */
  157.             exit(0);
  158.         }
  159.  
  160.         /* close output channel.. if we don't, the cli window can never close */
  161.         Close(_Backstdout);
  162.         /* let's have a look at our args */
  163.         for (dy=1;dy<argc;dy++) {
  164.             /* delay */
  165.             if ((strncmp(argv[dy],"-d",2))==0)
  166.                 if ((sscanf(argv[dy],"-d%d",&delay))<1 || delay<0) delay=1;
  167.             /* stay front */
  168.             if ((strncmp(argv[dy],"-f",2))==0) {
  169.                 StayFront=1;
  170.                 StayFrontGadget.Flags=GADGHCOMP|SELECTED;
  171.             }
  172.             /* alarm */
  173.             if ((strncmp(argv[dy],"-a",2))==0) {
  174.                 Alarm=1;
  175.                 AlarmGadget.Flags=GADGHCOMP|SELECTED;
  176.             }
  177.             /* set alarm time */
  178.             if ((strncmp(argv[dy],"-at",3))==0) {
  179.                 AlarmSet=1; alarmstring=argv[dy];
  180.             }
  181.             if ((strncmp(argv[dy],"-ot",3))==0) DTime=0; /* time off */
  182.             if ((strncmp(argv[dy],"-oy",3))==0) DDay=0; /* day off */
  183.             if ((strncmp(argv[dy],"-od",3))==0) DDate=0; /* date off */
  184.             if ((strncmp(argv[dy],"-of",3))==0) DFast=0; /* fast mem off */
  185.             if ((strncmp(argv[dy],"-oc",3))==0) DChip=0; /* chip mem off */
  186.             if ((strncmp(argv[dy],"-ol",3))==0) DTotal=0; /* total mem off */
  187.             if ((strncmp(argv[dy],"-u",2))==0) USA=1; /* usa backwards dates */
  188.             if ((strncmp(argv[dy],"-s",2))==0) Swap=1; /* auto go to 2nd screen */
  189.             /* new x position */
  190.             if ((strncmp(argv[dy],"-x",2))==0) {
  191.                 sscanf(argv[dy],"-x%d",&x);
  192.                 if (x<0) x=0;
  193.                 ClockWindow.LeftEdge=x;
  194.             }
  195.             /* new y position */
  196.             if ((strncmp(argv[dy],"-y",2))==0) {
  197.                 sscanf(argv[dy],"-y%d",&y);
  198.                 if (y<0) y=0;
  199.                 ClockWindow.TopEdge=y;
  200.             }
  201.         }
  202.     }
  203.  
  204.     if (delay>10) delay=10; delay*=1000000;
  205.     /* can't have no display; if asked for, at least show time */
  206.     if (DTime==0 && DDay==0 && DDate==0 && DFast==0 && DChip==0 && DTotal==0) DTime=1;
  207.     if (DTime) strcat(TextBuffer,"         ");
  208.     if (DDay) strcat(TextBuffer,"    ");
  209.     if (DDate) strcat(TextBuffer,"         ");
  210.     if (DFast) strcat(TextBuffer,"          ");
  211.     if (DChip) strcat(TextBuffer,"          ");
  212.     if (DTotal) strcat(TextBuffer,"           ");
  213.     /* now what was that alarm time ? */
  214.     if (AlarmSet) {
  215.         a=0; b=0; c=0;
  216.         sscanf(alarmstring,"-at%d:%d:%d",&a,&b,&c);
  217.         sprintf(AlarmBuffer,"%02d:%02d:%02d",a,b,c);
  218.     }
  219.     /* find out how wide window needs to be */
  220.     IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
  221.     ClockWindow.Screen=(struct Screen *) IntuitionBase->FirstScreen;
  222.     ClockWindow.Width=(strlen(TextBuffer)*8)+80;
  223.     if (ClockWindow.LeftEdge>(ClockWindow.Screen->Width)-ClockWindow.Width)
  224.         ClockWindow.LeftEdge=ClockWindow.Screen->Width-ClockWindow.Width;
  225.     if (ClockWindow.TopEdge>(ClockWindow.Screen->Height-10))
  226.         ClockWindow.TopEdge=ClockWindow.Screen->Height-10;
  227.     if ((Window=(struct Window *) OpenWindow(&ClockWindow))==NULL) bye();
  228.     /* if default font is too big, use topaz 8 */
  229.     if (Window->IFont->tf_YSize>8)
  230.         TextPrint.ITextFont=&TopazText;
  231.     if ((TimerPort=(struct MsgPort *) CreatePort("Timer Port",0))==NULL) bye();
  232.     if (OpenDevice(TIMERNAME,UNIT_VBLANK,&TimeReq,0)!=NULL) bye();
  233.     /* set up timer device request */
  234.     TimeReq.tr_node.io_Message.mn_ReplyPort=TimerPort;
  235.     TimeReq.tr_node.io_Command=TR_ADDREQUEST;
  236.     TimeReq.tr_node.io_Flags=0;
  237.     TimeReq.tr_node.io_Error=0;
  238.     TimeReq.tr_time.tv_secs=0;
  239.     TimeReq.tr_time.tv_micro=delay;
  240.     SendIO((char *) &TimeReq.tr_node);
  241.     /* lets go to next screen */
  242.     if (Swap==1)
  243.         if (nextscreen()) sizeflag=0;
  244.  
  245.     /* de main loop */
  246.     FOREVER {
  247.         if (StayFront==1) WindowToFront(Window); /* shove to front if asked for */
  248.         Chip=AvailMem(MEMF_CHIP)>>10; /* combien memory? */
  249.         Fast=AvailMem(MEMF_FAST)>>10;
  250.         Total=Chip+Fast;
  251.         getclk(d); /* neat lattice function */
  252.         stpdate(Date,3,&d[1]);
  253.         stptime(Time,2,&d[4]);
  254.         sscanf(Date,"%d-%d-%d",&mn,&dy,&yr);
  255.         if (USA==0) sprintf(Date,"%02d-%02d-%02d",dy,mn,yr); /* backwards :-) */
  256.         else sprintf(Date,"%02d-%02d-%02d",mn,dy,yr);
  257.         strcpy(buf,""); strcpy(TextBuffer,""); /* clear both buffers */
  258.         if (DTime) { strcat(TextBuffer," "); strcat(TextBuffer,Time); }
  259.         if (DDay) { strcat(TextBuffer," "); strcat(TextBuffer,Day[(int)d[0]]); }
  260.         if (DDate) { strcat(TextBuffer," "); strcat(TextBuffer,Date); }
  261.         if (DFast) { sprintf(buf," FAST:%-4d",Fast); strcat(TextBuffer,buf); }
  262.         if (DChip) { sprintf(buf," CHIP:%-4d",Chip); strcat(TextBuffer,buf); }
  263.         if (DTotal) { sprintf(buf," TOTAL:%-4d",Total); strcat(TextBuffer,buf); }
  264.         /* print it out! */
  265.         PrintIText(Window->RPort,&TextPrint,28,1);
  266.         /* check for alarm if asked */
  267.         if (Alarm==1)
  268.             if ((strncmp(Time,AlarmBuffer,8))==0)
  269.                 ringalarm(); /* alarm time! */
  270.         /* wait for a message */
  271.         Wait (1<<Window->UserPort->mp_SigBit | 1<<TimerPort->mp_SigBit);
  272.         
  273.         if (Msg=(struct IntuiMessage *) GetMsg(Window->UserPort)) {
  274.             class=Msg->Class; code=Msg->Code;
  275.             if (class==GADGETUP) {
  276.                 Gad=(struct Gadget *) Msg->IAddress;
  277.                 GadgetID=Gad->GadgetID;
  278.             }
  279.             ReplyMsg((struct Message *)Msg);
  280.             switch (class) {
  281.                 case CLOSEWINDOW: /* bye de bye */
  282.                     bye();
  283.                     break;
  284.  
  285.                 case MOUSEBUTTONS:
  286.                     if (code==MENUUP) {
  287.                         /* hit de right mouse button; resize */
  288.                         if (sizeflag==0) {
  289.                             /* make it big */
  290.                             ScreenHeight=Window->WScreen->Height;
  291.                             ScreenWidth=Window->WScreen->Width;
  292.                             oldx=Window->LeftEdge; oldy=Window->TopEdge;
  293.                             if (Window->TopEdge+45>ScreenHeight)
  294.                                 MoveWindow(Window,0,-((Window->TopEdge)-(ScreenHeight-45)));
  295.                             if (Window->LeftEdge+504>ScreenWidth)
  296.                                 MoveWindow(Window,-((Window->LeftEdge)-(ScreenWidth-504)),0);
  297.                             SizeWindow(Window,(504-ClockWindow.Width),35);
  298.                             AddGList(Window,&SwapScreensGadget,-1,6,NULL);
  299.                             RefreshGList(&SwapScreensGadget,Window,NULL,6);
  300.                             sizeflag=1;
  301.                         }
  302.                         else {
  303.                             /* make it small */
  304.                             RemoveGList(Window,&SwapScreensGadget,6);
  305.                             SizeWindow(Window,-(504-ClockWindow.Width),-35);
  306.                             if (oldx+ClockWindow.Width>Window->WScreen->Width)
  307.                                 oldx=Window->WScreen->Width-ClockWindow.Width;
  308.                             if (oldy+10>Window->WScreen->Height)
  309.                                 oldy=Window->WScreen->Height-10;
  310.                             MoveWindow(Window,oldx-Window->LeftEdge,oldy-Window->TopEdge);
  311.                             sizeflag=0;
  312.                         }
  313.                     }
  314.                     break;
  315.  
  316.                 case GADGETUP:
  317.                     /* a gadget! */
  318.                     switch (GadgetID) {
  319.                         case SWAPSCREENS: /* go to next screen */
  320.                             if (nextscreen()) sizeflag=0;
  321.                             break;
  322.  
  323.                         case STAYFRONT:
  324.                             /* toggle */
  325.                             if (StayFront==0) StayFront=1; else StayFront=0;
  326.                             break;
  327.  
  328.                         case ALARM:
  329.                             /* toggle */
  330.                             if (Alarm==0) Alarm=1; else Alarm=0;
  331.                             break;
  332.  
  333.                         case TIME:
  334.                             /* set the new time */
  335.                             a=0; b=0; c=0; ch='\0';
  336.                             if ((sscanf(TimeBuffer,"%d:%d:%d",&a,&b,&c))!=3 &&
  337.                                     (sscanf(TimeBuffer,"%d:%d",&a,&b))!=2 &&
  338.                                     (sscanf(TimeBuffer,"%d",&a))!=1) {
  339.                                 /* didn't work; not entered properly */
  340.                                 strcpy(TimeBuffer,"");
  341.                                 RefreshGList(&TimeStringGadget,Window,NULL,1);
  342.                                 break;
  343.                             }
  344.                             strcpy(TimeBuffer,"");
  345.                             RefreshGList(&TimeStringGadget,Window,NULL,1);
  346.                             d[4]=a; d[5]=b; d[6]=c;
  347.                             chgclk(d); /* another nifty lattice thingo */
  348.                             break;
  349.  
  350.                         case DATE:
  351.                             /* new date */
  352.                             if (USA==0) { a=d[3]; b=d[2]; c=d[1]+80; }
  353.                             else { a=d[2]; b=d[3]; c=d[1]+80; }
  354.                             if ((sscanf(DateBuffer,"%d-%d-%d",&a,&b,&c))!=3 &&
  355.                                     (sscanf(DateBuffer,"%d-%d",&a,&b))!=2 &&
  356.                                     (sscanf(DateBuffer,"%d",&a))!=1) {
  357.                                 strcpy(DateBuffer,"");
  358.                                 RefreshGList(&DateStringGadget,Window,NULL,1);
  359.                                 break;
  360.                             }
  361.                             strcpy(DateBuffer,"");
  362.                             RefreshGList(&DateStringGadget,Window,NULL,1);
  363.                             if (c<80) break;
  364.                             if (USA==0)    { d[1]=c-80; d[2]=b; d[3]=a; }
  365.                             else { d[1]=c-80; d[2]=a; d[3]=b; }
  366.                             chgclk(d);
  367.                             break;
  368.  
  369.                         case ALARMTIME:
  370.                             /* new al. time */
  371.                             a=0; b=0; c=0; ch='\0';
  372.                             sscanf(AlarmBuffer,"%d:%d:%d",&a,&b,&c);
  373.                             sprintf(AlarmBuffer,"%02d:%02d:%02d",a,b,c);
  374.                             RefreshGList(&AlarmStringGadget,Window,NULL,1);
  375.                             break;
  376.                     }
  377.                     break;
  378.             }
  379.         }
  380.         if (GetMsg(TimerPort)) {
  381.             TimeReq.tr_time.tv_secs=0;
  382.             TimeReq.tr_time.tv_micro=delay;
  383.             SendIO((char *) &TimeReq.tr_node);
  384.         }
  385.     }
  386. }
  387.  
  388. nextscreen()
  389. {
  390.     struct Screen *scr;
  391.     scr=Window->WScreen->NextScreen;
  392.     if (!scr || scr->Width<ClockWindow.Width || scr->Height<45) return(FALSE);
  393.     ScreenToBack(Window->WScreen);
  394.     ScreenToFront(scr);
  395.     ClockWindow.LeftEdge=Window->LeftEdge;
  396.     ClockWindow.TopEdge=Window->TopEdge;
  397.     ClockWindow.Screen=scr;
  398.     if (ClockWindow.LeftEdge+ClockWindow.Width>scr->Width)
  399.         ClockWindow.LeftEdge=scr->Width-ClockWindow.Width;
  400.     if (ClockWindow.TopEdge+10>scr->Height)
  401.         ClockWindow.TopEdge=scr->Height-10;
  402.     RemoveGList(Window,&SwapScreensGadget,6);
  403.     CloseWindow(Window);
  404.     if (!(Window=(struct Window *) OpenWindow(&ClockWindow))) bye();
  405.     return(TRUE);
  406. }
  407.  
  408. void bye()
  409. {
  410.     /* outahere! */
  411.     GetMsg(TimerPort);
  412.     if (TimeReq.tr_node.io_Message.mn_ReplyPort) CloseDevice(&TimeReq);
  413.     if (TimerPort) DeletePort(TimerPort);
  414.     if (Window) CloseWindow(Window);
  415.     if (IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
  416.     OpenWorkBench(); /* don't see how it could be closed, but.. */
  417.     exit(0);
  418. }
  419.  
  420. ringalarm()
  421. {
  422.     int i;
  423.     for (i=0;i<10;i++) {
  424.         DisplayBeep(NULL);
  425.         beep();
  426.         Delay(5);
  427.     }
  428.     return(0);
  429. }
  430.  
  431. UBYTE allocationMap[] = { 1, 8, 2, 4 };
  432.  
  433. beep()
  434. {
  435.     struct IOAudio *audioIOB;
  436.     struct MsgPort *replyPort;
  437.     UBYTE *beepWave;
  438.  
  439.     replyPort=(struct MsgPort *) CreatePort(0,0);
  440.     beepWave=(UBYTE *)AllocMem(10,MEMF_CHIP|MEMF_CLEAR);
  441.     if (beepWave!=0) {
  442.         beepWave[0]=100;
  443.         audioIOB=(struct IOAudio *)    CreateExtIO(replyPort,sizeof(struct IOAudio));
  444.         if (audioIOB!=NULL) {
  445.             audioIOB->ioa_Request.io_Message.mn_Node.ln_Pri=85;
  446.             audioIOB->ioa_Data=allocationMap;
  447.             audioIOB->ioa_Length=sizeof(allocationMap);
  448.             if (OpenDevice("audio.device",0,audioIOB,0)==0) {
  449.                 audioIOB->ioa_Request.io_Command=CMD_WRITE;
  450.                 audioIOB->ioa_Request.io_Flags=ADIOF_PERVOL;
  451.                 audioIOB->ioa_Data=beepWave;
  452.                 audioIOB->ioa_Length=10;
  453.                 audioIOB->ioa_Period=3579545/10000;
  454.                 audioIOB->ioa_Volume=64;
  455.                 BeginIO(audioIOB);
  456.                 Delay(50);
  457.                 CloseDevice(audioIOB);
  458.             }
  459.             DeleteExtIO(audioIOB);
  460.         }
  461.         FreeMem(beepWave,10);
  462.     }
  463.     DeletePort(replyPort);
  464.     return(0);
  465. }
  466.